﻿using System;
using GASS.CUDA;
namespace Cuda.Test
{
	class Program
	{
		private static CUDA _cuda;
		private static CudaTest _cudaTest;

		public static void CudaStart()
		{
			//+ Create a new instance of CUDA class, select 1st device. (create on worker thread)
			_cuda = new CUDA(0, true)
			{
				UseRuntimeExceptions = true,
			};
			if (_cuda != null)
			{
				Console.WriteLine("-- initializing CUDA");
				_cudaTest = new CudaTest(_cuda);
			}
			else
			{
				Console.WriteLine("-- CUDA not initalized");
				throw new Exception("CUDA not initalized");
			}
		}

		public static void CudaStop()
		{
			if (_cuda != null)
			{
				_cudaTest.Dispose();
				_cuda.Dispose(); _cuda = null;
			}
		}

		static void Main(string[] args)
		{
			try
			{
				CudaStart();
				_cudaTest.Test();
			}
			finally
			{
				CudaStop();
			}
			Console.WriteLine("done");
		}
	}
}
